package com.gewu.bookeeping.View.adapter;

import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.gewu.bookeeping.MyDb.bean.UserBeanIn;
import com.gewu.bookeeping.MyDb.dao.UserDaoPerson;
import com.gewu.bookeeping.OnClick.fourItemClieck;
import com.gewu.bookeeping.R;
import com.gewu.bookeeping.Utils.AppCot;

import java.util.List;

public class fourAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private List<String> lists = AppCot.fourList();
    private fourItemClieck fourItemClieck;

    public fourAdapter(com.gewu.bookeeping.OnClick.fourItemClieck fourItemClieck) {
        this.fourItemClieck = fourItemClieck;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.four_item2, parent, false);
        return new OneItems(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) {
        ((OneItems) holder).textView.setText(lists.get(position));
        ((OneItems) holder).textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fourItemClieck.onItemClieck(position);
            }
        });
    }

    @Override
    public int getItemCount() {
        return lists.size();
    }

    /**
     * 地步item的管理
     */
    private class OneItems extends RecyclerView.ViewHolder {

        TextView textView;

        public OneItems(View inflate) {
            super(inflate);
            textView = inflate.findViewById(R.id.texts);
        }
    }

}
